package main

import "fmt"

func corpFlightBookings(bookings [][]int, n int) []int {
	// 构建差分数组数组
	diff := make([]int, n+2)
	// 处理diff数组
	for _, booking := range bookings {
		diff[booking[0]] += booking[2]
		diff[booking[1]+1] -= booking[2]
	}
	//还原原数组
	for i := 1; i < n+1; i++ {
		diff[i] += diff[i-1]
	}
	//返回
	return diff[1 : n+1]
}

func main() {
	bookings := [][]int{{1, 2, 10},
		{2, 3, 20},
		{2, 5, 25}}
	n := 5
	ret := corpFlightBookings(bookings, n)
	fmt.Println(ret)
}
